var Web3 = require("web3")

var web3;

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
}
var faq = web3.eth.personal.newAccount("123456",function(error,result){
    if(!error)
	alert('register');
    console.log("账户注册：" + result);
});


var faq1 = web3.eth.getAccounts(function(error,result){
    if(!error)
    console.log("账户查询：" + result);
	alert('query');
});

var faq2 = web3.eth.personal.unlockAccount("0xCcf9a29D627C3227Cde654B7C12B246aB7FEB9FB","123456",function(error,result){
    if(!error)
    console.log("账户解锁：" + result);
	alert('unloke');
});

user1 = "0x50320119376c11E84FFbb1b12A89F8e0e7da07C2";
user2 = "0xCcf9a29D627C3227Cde654B7C12B246aB7FEB9FB";

var faq3 = web3.eth.sendTransaction({from:user1,to:user2,value:"100"},function(error,result){
    if(!error)
    console.log("账户转账：" + result);
	alert('move money');
});

var faq4 = web3.eth.getBalance("0xCcf9a29D627C3227Cde654B7C12B246aB7FEB9FB",function(error,result){
    if(!error)
    console.log("账户余额：" + result);
	alert('get balance');
});

